package com.sgb.kjwl.view.ui.adapter.self.logistics;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.transport.MotorcadListEntity;

import java.util.List;

/**
 * @author: 熊丽
 * @date: 2021/10/09 15:32
 * @Description: 车队列表适配器
 */
public class LinkedItemAdapter extends BaseQuickAdapter<MotorcadListEntity, BaseViewHolder> {

    public LinkedItemAdapter(@Nullable List<MotorcadListEntity> data) {
        super( R.layout.item_linked_fleet, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MotorcadListEntity item) {
        syncCommon(helper,item);
            syncLinked(helper,item);
    }
    /**
     * 设置公用信息
     */
    private void syncCommon(BaseViewHolder helper, MotorcadListEntity item) {
        helper.setText(R.id.tv_item_name,item.getMotorcadeName());
        helper.setText(R.id.tv_item_contacts_name,item.getName());
        helper.addOnClickListener(R.id.tv_item_fleet_edit);
        helper.addOnClickListener(R.id.tv_item_fleet_del);
        helper.addOnClickListener(R.id.cl_fleet_item);
    }

    /**
     * 同步竞
     */
    private void syncLinked(BaseViewHolder helper, MotorcadListEntity item) {
        helper.setVisible(R.id.ll_item_content,true);
        helper.setVisible(R.id.iv_item_fleet_status,true);
        helper.setText(R.id.tv_item_fleet_member_number,"共"+item.getDriverCount()+"人");
        helper.setText(R.id.tv_item_fleet_car_number,"共"+item.getCarCount()+"辆");
        helper.setText(R.id.tv_item_fleet_member,"共享司机");
        helper.setText(R.id.tv_item_fleet_car,"共享车辆");
        helper.setText(R.id.tv_item_fleet_edit,"解除挂靠");
        switch (item.getLinkState()){
            case "1":
                helper.setText(R.id.iv_item_fleet_status,"邀请中");
                helper.setTextColor(R.id.iv_item_fleet_status,helper.itemView.getResources().getColor(R.color.color_5792FD));
                helper.setVisible(R.id.tv_item_fleet_del,false);
                helper.setVisible(R.id.tv_item_fleet_edit,true);

                break;
            case "2":
                helper.setText(R.id.iv_item_fleet_status,"已拒绝");
                helper.setTextColor(R.id.iv_item_fleet_status,helper.itemView.getResources().getColor(R.color.color_FF4B10));
                helper.setVisible(R.id.tv_item_fleet_edit,false);
                helper.setVisible(R.id.tv_item_fleet_del,true);
                break;
            case "3":
                helper.setText(R.id.iv_item_fleet_status,"已同意");
                helper.setTextColor(R.id.iv_item_fleet_status,helper.itemView.getResources().getColor(R.color.color_06C764));
                helper.setVisible(R.id.tv_item_fleet_del,false);
                helper.setVisible(R.id.tv_item_fleet_edit,true);
                break;
            case "4":
                helper.setText(R.id.iv_item_fleet_status,"已解除");
                helper.setTextColor(R.id.iv_item_fleet_status,helper.itemView.getResources().getColor(R.color.color_969696));
                helper.setVisible(R.id.tv_item_fleet_edit,false);
                helper.setVisible(R.id.tv_item_fleet_del,true);
                break;
        }
    }

}
